package org.idea.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author zqx
 * @Date 2023-10-26
 */
@WebServlet("/ajax-jquery.do")
public class AjaxJqueryServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 设置响应的内容类型及编码 -- json -- application/json
        resp.setContentType("text/html;charset=utf-8");

        // msg=好好学习&hour=5
        String msg = req.getParameter("msg");
        String hour = req.getParameter("hour");

        System.out.println("消息：" + msg);
        System.out.println("时长：" + hour);

        PrintWriter out = resp.getWriter();

        out.println("天天向上");

        out.flush();
        out.close();
    }
}
